package com.example.lianguisystem.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;


@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private Boolean success;
    private String errorMsg;
    private Object data;
    private Integer total;
    private String code;


    public static Result success() {
        return new Result(true, null, null, null, null);
    }

    public static Result success(Object data) {
        return new Result(true, null, data, null, null);
    }
    public static Result success(Object data,String code) {
        return new Result(true, null, data, null, code);
    }

    public static Result success(List<?> data, Integer total) {
        return new Result(true, null, data, total, null);
    }

    public static Result success(List<?> data, Integer total, String code) {
        return new Result(true, null, data, total, code);
    }

    public static Result success(List<?> data, String code) {
        return new Result(true, null, data, null, code);
    }

    public static Result fail(String errorMsg,Object data) {
        return new Result(false, errorMsg, data, null, null);
    }
    public static Result fail(String errorMsg) {
        return new Result(false, errorMsg, null, null, null);
    }

}
